//
//  PPFavouritesCell.m
//  pickpic
//
//  Created by GaoYongyue on 16/8/27.
//  Copyright © 2016年 MicroDream. All rights reserved.
//

#import "PPFavouritesCell.h"
#import "PPFavouritesTimelineContentView.h"
#import "PPFavouriteModel.h"

static const CGFloat kContainerHPadding = 15.f;
static const CGFloat kContainerVPadding = 7.f;

@interface PPFavouritesCell ()

@property (nonatomic, strong) PPFavouritesTimelineContentView *feedContentView;

@end


@implementation PPFavouritesCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;

        _feedContentView = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([PPFavouritesTimelineContentView class]) owner:nil options:nil] firstObject];
        _feedContentView.frame = CGRectMake(kContainerHPadding, kContainerVPadding, [UIScreen mainScreen].bounds.size.width - 2*kContainerHPadding, 0);
        _feedContentView.layer.masksToBounds = YES;
        _feedContentView.layer.cornerRadius = 6.f;
        _feedContentView.layer.borderColor = [UIColor colorWithRGBHex:0x808080].CGColor;
        _feedContentView.layer.borderWidth = kLineWidth;
        [self.contentView addSubview:_feedContentView];

    }
    return self;
}

- (void)setAlbum:(PPAlbumObject *)album {
    _album = album;

    _feedContentView.album = album;
    _feedContentView.delegateViewController = _delegateViewController;
    _feedContentView.height = [PPFavouritesTimelineContentView heightForAlbum:album];
}


+ (CGFloat)heightForAlbum:(PPAlbumObject *)album {
    CGFloat height = 2*kContainerVPadding;
    height += [PPFavouritesTimelineContentView heightForAlbum:album];
    return height;
}


@end
